/**
 * @author VX5
 * @Title: MJC
 * @ProjectName interview
 * @Description: TODO
 * @date ${DAT}19:57
 */
public class Baidu01 {
    public String reslut(String s){
        if (s.length() == 0){
            return "";
        }
        char[] chars = s.toCharArray();
        int left = 0;
        int right = chars.length - 1;
        while (left < right){//字符串中只有一段是回文
            if (chars[left] == chars[right]){//遇到相同的字符开始判断是否存在回文
                chars[left] = ' ';
                chars[right] = ' ';
                left++;
                right--;
                if (left == right){
                    chars[left] = ' ';
                }
            }else {
                right--;
            }
        }
        StringBuilder builder = new StringBuilder();
        for (char aChar : chars) {
            if (aChar != ' '){
                builder.append(aChar);
            }
        }
        String res = builder.toString();
        return res;
    }

    public static void main(String[] args) {
        System.out.println(new Baidu01().reslut("abcbad"));
    }
}
